﻿using Newtonsoft.Json.Linq;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Text.Json;
using System.Threading.Tasks;
using System.Windows.Forms;
using Traceability.Commont.Domains.AnimalsDomainFiles;

namespace Butcher.winform.EnterpriseForms
{
    public partial class ScaleTypeAdd : Form
    {
        public ScaleTypeAdd()
        {
            InitializeComponent();
        }

        private void uiButton1_Click(object sender, EventArgs e)
        {
            var sh = 0;
            string url = @"http://localhost:5229/api/Section/ScaleTypeAdd";
            HttpClient client = new HttpClient();
            ScaleType st = new ScaleType();
            st.ScaleTypename = ScaleTypenamed.Text;
            var content = new StringContent(JsonSerializer.Serialize<ScaleType>(st));
            content.Headers.Remove("Content-Type");
            content.Headers.Add("Content-Type", "application/json");
            string result = client.PostAsync(url, content).Result.Content.ReadAsStringAsync().Result;
            JObject info = JObject.Parse(result);
            var aaa = result;
            aaa = info["messges"].Value<string>();
            if(aaa != null && ScaleTypenamed.Text != "")
            {
                sh = 1;
                MessageBox.Show("磅秤类型新增成功");
            }
            else
            {
                sh = 0;
                MessageBox.Show("磅秤类型新增失败");
            }
        }
    }
}
